/**
 * schemas 
 */
var mongoose = require('mongoose');
module.exports = {

    student: {
        mobile          : {type : String},
        password        : {type : String, default: 's123456'},
        sex             : {type : Number, default : 1},
        age             : {type : Number},
        nickerName      : {type : String, default  : 'kid' },
        email           : {type : String},
        referenceId     : {type : String},
        qq              : {type : String},
        wechat          : {type : String},
        avatar          : {type : String, default: '4'}, 
        address         : {type : String, default: ''},
        openId          : {type : String, default: ''},
        remark          : {type : String, default: ''}
    },
    teacher: {
        email           : {type : String, required : true, unique : true},
        password        : {type : String, default: 't123456'}, //MD5格式, 原始密码为6-18位字符+数字组合
        fullName        : {type : String},
        sex             : {type : Number, default : 1},
        age             : {type : Number},
        mobile          : {type : String},
        nationality     : {type : String},
        city            : {type : String},
        timeZone        : {type : String},
        avatar          : {type : String},
        videoUrl        : {type : String},
        introduction    : {type : String},
        activated       : {type : String, default : '1'},
        classes         : {type : [String]}, //外教所有班级,班级名称格式为: R10001, R10003
        remark          : {type: String, default: ''}
    },
    class: {
        name            : {type: String, required: true, unique: true},
        grade           : {type: String},
        totalCourses    : {type: Number},   // 多少次课
        progress        : {type: Number},   // 上课进度
        start           : {type: Date}, 
        studentIds      : [{type: mongoose.Schema.ObjectId, ref: 'Student'}],
        teacherId       : {type: mongoose.Schema.ObjectId, ref: 'Teacher'},
        classTimes      : [{
            dayOfWeek   : {type: Number,  min:1, max:7}, //1-7分别表示Monday-Sunday
            startHour   : {type: String},
            startMinute : {type: String},
            endHour     : {type: String},
            endMinute   : {type: String}
        }],
        remark          : {type: String}
    },
    // 课程表，包括所有老师的课程，包括空闲的和上课的
    schedule: {
        studentIds      : [{type: mongoose.Schema.ObjectId, ref: 'Student'}],
        teacherId       : {type: mongoose.Schema.ObjectId, ref: 'Teacher', required: true},
        start           : {type: Date, required: true},
        end             : {type: Date, required: true},
        status          : {type: Number, default: 0},  // 状态， 0 空闲， 1 预定 2 异常
        className       : {type: String, default: ''}
    },
    // 教师可用时间
    teacherSchema: {
        teacherId   : {type: mongoose.Schema.ObjectId, ref: 'Teacher'},
        dayOfWeek   : {type: Number,  min:1, max:7}, //1-7分别表示Monday-Sunday
        startHour   : {type: String},
        startMinute : {type: String},
        endHour     : {type: String},
        endMinute   : {type: String}
    }
}